cd "$data_path"
use "dataset", clear

global basic_controls "female age age2 educ_low_sec educ_high_sec educ_higher length length_2 length_3 married children house_ entit ipart1 ipart2 ipart3 ipart4 ipart5"
global search_controls ""

* Define estimation sample
reg lres t i.land L(0).lagg_unemp $basic_controls if age<65 & pgisced!=. & part!=0 & age>15 & first_spell!=1 & west==1
gen sample_used=1 if e(sample)

* Generate state-specific trends
forvalue j=1/16 {
    gen t_la`j' = t*lak`j'
}

* Column 4: Fixed effects with current unemployment
xtivreg2 lres t t2 lak* lagg_unemp $basic_controls $search_controls (lben = month2 getb) if sample_used==1, fe cluster(pid svyyear)
outreg2 lagg_unemp using "$output/Table2.xls", excel replace title("Table 2: Estimates of Reservation Wage Equations for Germany") ctitle("Germany (1984-2010)") label addtext(Individual fixed effects, Yes) keep(lagg_unemp) dec(3) sdec(3)

* Column 5: Fixed effects with lagged unemployment
xtivreg2 lres t t2 lak* mlagg $basic_controls $search_controls (lben = month2 getb) if sample_used==1, fe cluster(pid svyyear)
outreg2 mlagg using "$output/Table2.xls", excel append ctitle("Germany (1984-2010)") label addtext(Individual fixed effects, Yes) keep(mlagg) dec(3) sdec(3)
